package com.lxg;

import com.lxg.dao.BookDao;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author 陆小根
 * date: 2022/04/24
 * Description:
 * BeanFactory创建完毕后，所有bean均为延迟加载   当获取bean中的对象才会去初始化该对象
 */

public class AppForBeanFactory {
  public static void main(String[] args) {

    Resource resources = new ClassPathResource("applicationContext.xml");
    BeanFactory bf = new XmlBeanFactory(resources);
    BookDao bookDao = bf.getBean("bookDao", BookDao.class);
    bookDao.save();
  }
}
